package cn.baage.campus.utils;

import cn.hutool.core.util.StrUtil;
import lombok.Data;

import java.util.Objects;

/**
 * @Description: 分页对象
 * @Author: 八阿哥
 * @url: baage.cn
 * @Version: 1.0
 **/
@Data
public class PageDomain
{
    /** 页码，从1开始 */
    private Integer pageNum;

    /** 每页显示记录数 */
    private Integer pageSize;

    /** 排序列 */
    private String orderByColumn;

    /** 排序的方向desc或者asc */
    private String isAsc = "asc";

    /** 分页参数合理化 */
    private Boolean reasonable = true;

    public String getOrderBy()
    {
        if (StrUtil.isEmpty(orderByColumn)) {
            return "";
        }
        return StrUtil.toUnderlineCase(orderByColumn).toLowerCase() + " " + isAsc;
    }


    public Boolean getReasonable()
    {
        if (Objects.isNull(reasonable)) {
            return Boolean.FALSE;
        }
        return reasonable;
    }
}
